/*
 * Copyright (C) 2008 GeoScheduler team, as stated on <http://www.geoscheduler.org/>.
 * 
 * This file is part of GeoScheduler.
 * 
 * GeoScheduler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GeoScheduler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with GeoScheduler. If not, see <http://www.gnu.org/licenses/>.
 */
package org.geoscheduler.android.activities;


import org.geoscheduler.android.GSContext;
import org.geoscheduler.android.R;
import org.geoscheduler.android.alerts.AlertHelper;
import org.geoscheduler.android.sync.SyncEventsHelper;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * Temporary Main Activity of GeoScheduler client application
 * 
 * @author paja 
 */
public class GSMain extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		
		setContentView(R.layout.dummy);
		
		/* This Context to be used in inner classes */
		final Context ctx = this;
		
		/* Initialize GSContext */
		GSContext.loadPrefs(ctx);

		/* Edit page button */
		Button btnMo = (Button) findViewById(R.id.dummy_map_overview);
		btnMo.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
		        Intent moEvent = new Intent();
		        moEvent.setClassName("org.geoscheduler.android", MapOverview.class.getName());

				startActivity(moEvent);
			}
		});

		/* List page button */
		Button btnLp = (Button) findViewById(R.id.dummy_listpage);
		btnLp.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
		        Intent listevents = new Intent();
		        listevents.setClassName("org.geoscheduler.android", "org.geoscheduler.android.activities.ListEvents");

				startActivity(listevents);
			}
		});

		/* Setup button */
		Button btnSetup = (Button) findViewById(R.id.dummy_setup);
		btnSetup.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
		        Intent setup = new Intent();
		        setup.setClassName("org.geoscheduler.android", "org.geoscheduler.android.activities.Setup");

				startActivity(setup);
			}
		});

		/* Google account development button */
		Button btnGAcc = (Button) findViewById(R.id.dummy_gacc);
		btnGAcc.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
		        Intent login = new Intent();
		        login.setClassName("org.geoscheduler.android", Login.class.getName());

				startActivity(login);
			}
		});

		/* Reg timers button */
		Button btnReg = (Button) findViewById(R.id.dummy_reg_alertintent);
		btnReg.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
				AlertHelper.registerIntent(GSMain.this);
		        SyncEventsHelper.registerIntent(GSMain.this);
		        
		        Toast.makeText(GSMain.this, R.string.services_msg_started_both, Toast.LENGTH_SHORT).show();
			}
		});

		/* Unreg timers button */
		Button btnUnreg = (Button) findViewById(R.id.dummy_unreg_alertintent);
		btnUnreg.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
				AlertHelper.unregisterIntent(GSMain.this);
		        SyncEventsHelper.unregisterIntent(GSMain.this);
		        
		        Toast.makeText(GSMain.this, R.string.services_msg_stopped_both, Toast.LENGTH_SHORT).show();
			}
		});
		
//		/* PopUp button */
//		Button popUp = (Button) findViewById(R.id.dummy_popup);
//		popUp.setOnClickListener(new View.OnClickListener() {
//			
//			@Override
//			public void onClick(View arg0) {
//				
//				EditText et = (EditText)findViewById(R.id.dummy_popup_id);
//				
//				Intent i = new Intent(GSMain.this, AlertPopup.class);
//				long id = Long.parseLong(et.getText().toString());
//				i.putExtra(AlertPopup.class.getName() + AlertPopup.PAR_EVENT_ID, id);
//				startActivity(i);
//			}
//		});

	}

}
